/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author Monster
 */
public class NamDoc extends QuaiVat{
    public NamDoc(Sprite _sprite,int x,int y) {
        super(_sprite, x, y);        
        _sprite.defineCollisionRectangle(1, 1, 28, 28);
    }
    public void ViTriDauTien(int x, int y) {
        super.ViTriDauTien(x, y);
    }  
    
    public void HoatDong() {
        super.HoatDong();
        Timer timer=new Timer();
        this.moving=true;
        TimerTask timertask= new TimerTask() {

            public void run() {
                if(moving){
                    _sprite.nextFrame();
                }
            }
        }; 
        
        timer.scheduleAtFixedRate(timertask, 0,200);
        GameDesign design=new GameDesign();
        movement=new NamDocMovement(_sprite);
        movement.ThemVatCanDong(VatCanDong, iVatCanDong);
        movement.ThemDoiTuongGayHai(DoiTuongGayHai,this.iDoiTuongGayHai);
        movement.ThemVatCanTinh(VatCanBinhThuong,this.iVatCanBinhThuong);
        movement.setSequences(design.Monster01_down,design.Monster01_up, design.Monster01_left, design.Monster01_right);        
        (new Thread(movement)).start();        
    }
}
